package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategoryMapper {

    Page<Category> pageQuery(@Param("name") String name, @Param("type") Integer type);

    //Page<Category> getListByType(Integer type);
    List<Category> getListByType(Integer type);

    void changeStatus(@Param("status") Integer status, @Param("id") Long id);

    @AutoFill(OperationType.INSERT)
    void save(Category category);

    @Select("select * from category where name=#{name}")
    Category getByName(String name);

    @AutoFill(OperationType.UPDATE)
    void update(Category category);

    @Delete("delete from category where id=#{id}")
    void deleteById(Long id);

    @Select("select * from category where id=#{categoryId}")
    Category getCategoryById(Long categoryId);
}
